package org.yray.yaml.utils;

import org.yray.yaml.PodObj;
import org.yray.yaml.YamlObject;

import java.io.File;

public class YamlUtils {

    public static void createPod(PodObj podObj)
    {
        String proName=podObj.getProName();
        String baseYamlFileName="backent_common__disk_nfs.yaml";
        String path=FileUtils.getPath(baseYamlFileName);
        String saveYamlFileName=".yaml";
        YamlObject yamlObject=new YamlObject(path+ File.separator+baseYamlFileName);
        yamlObject.setVal("metadata.labels.app",proName);
        yamlObject.setVal("metadata.name",proName);
        yamlObject.setVal("spec.selector.matchLabels.app",proName);
        yamlObject.setVal("spec.template.metadata.labels.app",proName);
        yamlObject.setVal("spec.template.spec.containers.name",proName);
        yamlObject.setVal("spec.template.spec.containers.image","yykj-image01.tencentcloudcr.com/dev-050101fsc/"+proName+":1");
        yamlObject.setVal("spec.template.spec.containers.ports.containerPort",podObj.getPort());
        yamlObject.setVal("spec.template.spec.containers.readinessProbe.httpGet.port",podObj.getPort());
        yamlObject.saveFile(path+File.separator+proName+saveYamlFileName);
    }
}
